package com.ruoyi.security.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.security.mapper.AfChemicalsMapper;
import com.ruoyi.security.domain.AfChemicals;
import com.ruoyi.security.service.IAfChemicalsService;

/**
 * 危化品Service业务层处理
 *
 * @author cjie
 * @date 2021-07-24
 */
@Service
public class AfChemicalsServiceImpl implements IAfChemicalsService {
    @Autowired
    private AfChemicalsMapper afChemicalsMapper;

    /**
     * 查询危化品
     *
     * @param id 危化品ID
     * @return 危化品
     */
    @Override
    public AfChemicals selectAfChemicalsById(String id) {
        return afChemicalsMapper.selectAfChemicalsById(id);
    }

    /**
     * 查询危化品列表
     *
     * @param afChemicals 危化品
     * @return 危化品
     */
    @Override
    public List<AfChemicals> selectAfChemicalsList(AfChemicals afChemicals) {
        return afChemicalsMapper.selectAfChemicalsList(afChemicals);
    }

    /**
     * 新增危化品
     *
     * @param afChemicals 危化品
     * @return 结果
     */
    @Override
    public int insertAfChemicals(AfChemicals afChemicals) {
        afChemicals.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        afChemicals.setCreateTime(DateUtils.getNowDate());
        afChemicals.setCreateBy(SecurityUtils.getUsername());
        return afChemicalsMapper.insertAfChemicals(afChemicals);
    }

    /**
     * 修改危化品
     *
     * @param afChemicals 危化品
     * @return 结果
     */
    @Override
    public int updateAfChemicals(AfChemicals afChemicals) {
        afChemicals.setUpdateTime(DateUtils.getNowDate());
        afChemicals.setUpdateBy(SecurityUtils.getUsername());
        return afChemicalsMapper.updateAfChemicals(afChemicals);
    }

    /**
     * 批量删除危化品
     *
     * @param ids 需要删除的危化品ID
     * @return 结果
     */
    @Override
    public int deleteAfChemicalsByIds(String[] ids) {
        return afChemicalsMapper.deleteAfChemicalsByIds(ids);
    }

    /**
     * 删除危化品信息
     *
     * @param id 危化品ID
     * @return 结果
     */
    @Override
    public int deleteAfChemicalsById(String id) {
        return afChemicalsMapper.deleteAfChemicalsById(id);
    }
}
